package com.xiaoshuidi.cloud.module.finance.controller.admin.finance.vo.flow;

import com.xiaoshuidi.cloud.module.finance.enums.finance.SourceBizTypeEnum;
import com.xiaoshuidi.cloud.module.finance.enums.order.FinanceCommonStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "管理后台 - 财务管理 - 交易流水 Response VO")
@Data
public class FinanceMoneyFlowRespVO {
    private Long id;
    /**
     * 交易流水编号
     **/
    @Schema(description = "交易流水编号")
    private String flowNo;
    /**
     * 商户线上交易订单号
     **/
    @Schema(description = "商户线上交易订单号")
    private String merchantOrderId;
    /**
     * 线下交易单号/线上支付第三方交易号
     **/
    @Schema(description = "线下交易单号/线上支付第三方交易号")
    private String tradeNo;
    /**
     * 线下交易账号(转账等)
     **/
    @Schema(description = "线下交易账号(转账等)")
    private String tradeAccount;


    /**
     * 流入0,流出1
     **/
    @Schema(description = "流入0,流出1")
    private Integer direction;
    /**
     * 交易来源, 线上(ONLINE)/线下(OFFLINE)
     **/
    @Schema(description = "交易来源, 线上(ONLINE)/线下(OFFLINE)")
    private String sourceFrom;

    @Schema(description = "交易来源, 线上(ONLINE)/线下(OFFLINE)")
    private String sourceFromDesc;
    /**
     * 支付方式
     **/
    @Schema(description = "支付方式")
    private String payMethod;

    /**
     * 实际交易金额
     **/
    @Schema(description = "实际交易金额")
    private BigDecimal actualPaymentAmount;
    /**
     * 交易金额
     **/
    @Schema(description = "交易金额")
    private java.math.BigDecimal tradeAmount;

    @Schema(description = "优惠金额")
    private BigDecimal discount;
    /**
     * 租赁合同号
     **/
    @Schema(description = "租赁合同号")
    private String roomContractNo;
    /**
     * 合同账单编号
     **/
    @Schema(description = "合同账单编号")
    private String roomRentOrderNo;
    /**
     * 合同账单开始
     **/
    @Schema(description = "合同账单开始")
    private LocalDate roomRentOrderStart;
    /**
     * 合同账单结束
     **/
    @Schema(description = "合同账单结束")
    private LocalDate roomRentOrderEnd;
    /**
     * 部门/门店id
     **/
    @Schema(description = "部门/门店id")
    private Integer storeId;
    /**
     * 门店名称
     **/
    @Schema(description = "门店名称")
    private String storeName;
    /**
     * 公寓id
     **/
    @Schema(description = "公寓id")
    private Integer apartmentId;
    /**
     * 公寓名称
     **/
    @Schema(description = "公寓名称")
    private String apartmentName;
    /**
     * 房间id
     **/
    @Schema(description = "房间id")
    private Long roomId;
    /**
     * 房间名称
     **/
    @Schema(description = "房间名称")
    private String roomName;
    /**
     * 承租人
     **/
    @Schema(description = "承租人")
    private String renter;
    /**
     * 租客姓名
     **/
    @Schema(description = "租客姓名")
    private String rentCustomer;
    /**
     * 交易对象姓名
     **/
    @Schema(description = "交易对象姓名")
    private String trader;
    /**
     * 经办人姓名
     **/
    @Schema(description = "经办人姓名")
    private String operator;
    /**
     * 交易日期
     **/
    @Schema(description = "交易日期")
    private LocalDateTime tradeTime;
    /**
     * 交易操作完成日期
     **/
    @Schema(description = "交易操作完成日期")
    private LocalDateTime payTime;
    /**
     * 交易关联业务id
     */
    private String sourceBizId;
    /**
     * 交易关联业务类型
     * {@link com.xiaoshuidi.cloud.module.finance.enums.finance.SourceBizTypeEnum}
     */
    private String sourceBizType;
    /**
     * 备注
     **/
    @Schema(description = "备注")
    private String remark;
    /**
     * 附件
     **/
    @Schema(description = "附件")
    private String attachment;
    /**
     * 交易状态
     * {@link FinanceCommonStatusEnum}
     **/
    @Schema(description = "状态")
    private String status;

    @Schema(description = "状态描述")
    private String statusDesc;

    private LocalDateTime createTime;
    /**
     * 勾核人
     **/
    private String checkedBy;

    /**
     * 驳回原因
     */
    private String rejectReason;

    /**
     * 费项列表
     */
    @Schema(description = "费项列表")
    private List<FinanceOrderFeeVO> feeList;

    public String getFeeType() {
        try {
            SourceBizTypeEnum type = SourceBizTypeEnum.valueOf(sourceBizType);
            switch (type) {
                case ACCOUNT_RECHARGE:
                    return "预充值";
                case RENT_ORDER:
                    return "多费项";
                case ROOM_RESERVE:
                    return "定金";
                default:
                    return "";
            }
        } catch (Exception ignore) {
        }
        return "";
    }
}
